//
//  BK_my_EvaluationOfDryingCell.m
//  bestkeep
//
//  Created by 李明 on 2016/11/30.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BK_my_EvaluationOfDryingCell2.h"
#import "Masonry.h"

@implementation BK_my_EvaluationOfDryingCell2
static NSString *string = @"长度在10-500字之间,写下购买体会可以为其他小伙伴提供参考";
- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)initializeCell:(CellModel *)cellModel {
   // self.delegate = cellModel.delegate;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor whiteColor];
        _informationTextView = [[UITextView alloc] init];
        _informationTextView.backgroundColor = [UIColor whiteColor];
        _informationTextView.font = [UIFont systemFontOfSize:13.0];
        _informationTextView.textColor = HexColor(0xB2B2B2);
        _informationTextView.delegate = self;
        _informationTextView.text = string;
        
        [self.contentView addSubview:_informationTextView];
        [_informationTextView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.contentView.mas_top).offset(5);
            make.right.mas_equalTo(self.contentView.mas_right).offset(-ApplicationBackGauge);
            make.left.mas_equalTo(self.contentView.mas_left).offset(ApplicationBackGauge);
            make.height.mas_equalTo(@(130));
        }];
    }
        return self;
}

- (void)textViewDidBeginEditing:(UITextView *)textView {
    
    if ([textView.text isEqualToString:string]) {
        textView.text = @"";
    }
    textView.textColor = HexColor(0x404040);
}

- (void)textViewDidEndEditing:(UITextView *)textView {
    if (textView.text.length < 1) {
        textView.text = string;
        textView.textColor = HexColor(0xB2B2B2);
    }else if (textView.text.length > 500) {
        textView.text = [textView.text substringToIndex:500];
    }else {
        
    }
}

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
    if (textView.text.length > 500) {
        textView.text = [textView.text substringToIndex:500];
        return NO;
    }
    return YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
